package io.renren.modules.norminfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.welderradio.entity.WelderradioEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.norminfo.entity.NorminfoEntity;
import io.renren.modules.norminfo.service.NorminfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-12-25 17:21:40
 */
@RestController
@RequestMapping("norminfo/norminfo")
public class NorminfoController {
    @Autowired
    private NorminfoService norminfoService;

    @GetMapping("getnorminfo")
    public List<NorminfoEntity> getnorminfo(@RequestParam(value = "normid",required = false) String normId, @RequestParam(value = "normdescribr",required = false) String normDescribr){
        return norminfoService.getnorminfo(normId,normDescribr);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("norminfo:norminfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = norminfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{normid}")
    @RequiresPermissions("norminfo:norminfo:info")
    public R info(@PathVariable("normid") String normid){
		NorminfoEntity norminfo = norminfoService.getById(normid);

        return R.ok().put("norminfo", norminfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("norminfo:norminfo:save")
    public R save(@RequestBody NorminfoEntity norminfo){
		norminfoService.save(norminfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("norminfo:norminfo:update")
    public R update(@RequestBody NorminfoEntity norminfo){
		norminfoService.updateById(norminfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("norminfo:norminfo:delete")
    public R delete(@RequestBody Integer[] normids){
		norminfoService.removeByIds(Arrays.asList(normids));

        return R.ok();
    }

}
